package cn.itcast.order.web;


import cn.itcast.order.pojo.Order;

import cn.itcast.order.service.OrderService;
import com.example.clients.UserClient;
import com.example.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("order")
public class OrderController {

    @Autowired
    private UserClient userClient;
    @Autowired
    private OrderService orderService;
    @Value("${server.port}")
    private int port;

    @GetMapping("{orderId}")
    public Order queryOrderByUserId(@PathVariable("orderId") Long orderId) {
        // 根据id查询订单并返回
        Order order = this.orderService.queryOrderById(orderId);
        System.out.println(order);

        return order;
    }

    @GetMapping("save")
    public String save() {
        User user = new User();
        user.setId(5L);
        user.setUsername("dalao");
        user.setAddress("m78");
        String s = userClient.save(user);
        return s;
    }
}
